function [] = visualMat(filename, dim)
    close all;
    if (dim == 2)
        fin = fopen(filename, 'r');
        [data count] = fscanf(fin, '(%g, %g)', [2 inf]);
        fclose(fin);
        scatter(data(1,:), data(2,:));
    end
    if (dim == 3)
        fin = fopen(filename, 'r');
        [data count] = fscanf(fin, '\t(%g, %g, %g)', [3 inf]);
        fclose(fin);
        if (max(max(max(data))) >= 1)
            colorScale = 255;
        else
            colorScale = 1;
        end
        data = sort(data, 2);

        figure;
        subplot(2,2,1);
        colors = zeros(size(data,2), 3);
        colors(:, 1) = 0.7;
        start = 1;
        cnt = 1;
        for ii = 2 : size(data, 2)
            if (data(:,ii) == data(:,start))
                cnt = cnt+1;
            else
                colors(start:ii-1,2) = min([double(cnt)/100, 1]);
                start = ii;
                cnt = 1;
            end
        end
        scatter3(data(1,:), data(2,:), data(3,:), 20, colors, 'filled');

        subplot(2,2,2);
        colors = zeros(size(data,2), 3);
        colors(:, 1) = 0.7;
        colors(:, 2) = double(data(3,:)) ./ double(colorScale);
        scatter(data(1,:), data(2,:), 20, colors, 'filled');
        subplot(2,2,3);
        colors(:, 2) = double(data(2,:)) ./ double(colorScale);
        scatter(data(1,:), data(3,:), 20, colors, 'filled');
        subplot(2,2,4);
        colors(:, 2) = double(data(1,:)) ./ double(colorScale);
        scatter(data(2,:), data(3,:), 20, colors, 'filled');        
    end
end
